#encoding: utf-8

# class Person(object):
# 	"""docstring for Person"""

# 	 # 限定Person对象只能绑定_name, _age属性
# 	__slots__ = ('_name', '_age')

# 	def __init__(self, name, age):
# 		super(Person, self).__init__()
# 		self._name = name
# 		self._age = age

# 	@property
# 	def name(self):
# 		return self._name

# 	@property
# 	def age(self):
# 		return self._age
	

# 	@age.setter
# 	def age(self, age):
# 		# (PS: 第一次在这边设置： self.age = age ) 导致死循环
# 		self._age = age 
# 		pass

# 	def play(self):
# 		if self.age > 18:
# 			print('%s 正在玩飞行棋' % self._name)
# 		else :
# 			print('%s 都地主' % self._name)
# 			pass
# 		pass

# def main():
# 	person = Person("王大锤", 19)
# 	person.play()

# 	person.age = 15
# 	person.play()
# 	# person.name = 'xxxx' AttributeError: can't set attribute

# 	a = A()
# 	a.foo(1)
# 	# A.foo(1)   # foo可通过实例a调用，类对像A直接调用会参数错误。

# 	A.foo(a, 1)
# 	A.class_foo(1)

# 	A.static_foo(1)

# 	a.static_foo(1)

# 	pass

# class A(object):
#     def foo(self, x):
#         print("executing foo(%s,%s)" % (self, x))
#         print('self:', self)
#     @classmethod
#     def class_foo(cls, x):
#         print("executing class_foo(%s,%s)" % (cls, x))
#         print('cls:', cls)
#     @staticmethod
#     def static_foo(x):
#         print("executing static_foo(%s)" % x)    


# if __name__ == '__main__':
# 	main()


# 抽象类

from abc import ABCMeta, abstractmethod

class Pet(object, metaclass=ABCMeta):
	# __metaclass__ = ABCMeta

	"""docstring for Pet"""
	def __init__(self, nickName):
		super(Pet, self).__init__()
		self.nickName = nickName
		
	@abstractmethod
	def make_voice(self):
		""" make voice """
		pass


class Dog(Pet):
	def make_voice(self):
		print('%s 汪汪汪 ' % self.nickName)
		pass
		
class Cat(Pet):
	"""docstring for Cat"""
	def make_voice(self):
		print('%s 喵喵喵' % self.nickName)
		pass
		
def main():
	pets = [Dog("旺财") , Cat('大猫')]
	for pet in pets:
		pet.make_voice()
		pass

if __name__ == '__main__':
	main()






























